var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
    name:'imageServer',
    description: 'The nodejs image Server.',
    script: 'F:\\xiaoyiGIT\\imageServer\\index.js',
    wait : 1,
    grow:'1',
    maxRestarts:20
});

// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
    svc.start();
    console.log('install complete');
});

svc.on('uninstall', () =>{
    console.log('Uninstall complete');
    console.log('The service exits: ', svc.exists);
})

svc.on('alreadyinstalled', ()=>{
    console.log('this server is already installed');
});

if(svc.exists) return svc.uninstall();

svc.install();